﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using BUS;
using DataTransfer;
namespace Gui
{
    public partial class frmPhieuKhamChiTiet : DevComponents.DotNetBar.Office2007Form
    {
        frmLapPhieuKhamBenh frm_lapphieukham;
        public frmPhieuKhamChiTiet(frmLapPhieuKhamBenh frm)
        {
            InitializeComponent();
            frm_lapphieukham = frm;
        }

        private void frmPhieuKhamChiTiet_Load(object sender, EventArgs e)
        {
            load();
        }
        private void load()
        {
            ThuocBus thuocBus = new ThuocBus();
            cbxThuoc.DataSource = thuocBus.GetAll();
            cbxThuoc.DisplayMember = "TenThuoc";
            cbxThuoc.ValueMember="ID";

            DonViBus donviBus = new DonViBus();
            cbxDonVi.DataSource = donviBus.GetAll();
            cbxDonVi.DisplayMember = "TenDonVi";
            cbxDonVi.ValueMember = "ID";

            CachDungBus cachdungBus = new CachDungBus();
            cbxCahDung.DataSource =cachdungBus.GetAll();
            cbxCahDung.DisplayMember = "TenCachDung";
            cbxCahDung.ValueMember = "ID";
        }

        private void btnThoat_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void btnThem_Click(object sender, EventArgs e)
        {
            ThuocBus thuocBus = new ThuocBus();
            DonViBus donViBus = new DonViBus();
            CachDungBus cachdungBus = new CachDungBus();
            string idthuoc = cbxThuoc.SelectedValue.ToString();
            string tenthuoc = thuocBus.Get(Convert.ToInt32(idthuoc)).TenThuoc;
            string soluong = txtSoLuong.Text;
            string donVi = donViBus.Get(Convert.ToInt32(cbxDonVi.SelectedValue.ToString())).TenDonVi;
            string cachdung = cachdungBus.Get(Convert.ToInt32(cbxCahDung.SelectedValue.ToString())).TenCachDung;

            string[] row = new string[] { idthuoc, tenthuoc, donVi, soluong, cachdung };
           
           frm_lapphieukham.addrow(row);
           frm_lapphieukham.refresh();

        }

    }
}
